Crate ewebsock

Source
Expand description

A WebSocket client library that can be compiled to both native and the web (WASM).

Usage:

let options = ewebsock::Options::default();
let (mut sender, receiver) = ewebsock::connect("ws://example.com", options).unwrap();
sender.send(ewebsock::WsMessage::Text("Hello!".into()));
while let Some(event) = receiver.try_recv() {
    println!("Received {:?}", event);
}

§Feature flags

  • tokio — Opt-in to the tokio executor.

    This adds a lot of dependencies, but may yield lower latency and CPU usage when using ws_connect.

    Will ignore any ControlFlow::Break returned from the on_event callback.

Structs§

Enums§

Functions§

  • Connect to the given URL, and return a sender and receiver.
  • Like connect, but will call the given wake-up function on each incoming event.
  • Connect and call the given event handler on each received event.
  • Connect and call the given event handler on each received event.

Type Aliases§

  • An error.
  • Short for Result<T, ewebsock::Error>.